﻿#ifndef INSTRUCTIONTURNTABLEOPENCIRCUIT
#define INSTRUCTIONTURNTABLEOPENCIRCUIT

#include "ScriptInstruction.h"

class InstructionTurnTableOpenCircuit :public ScriptInstruction
{
  Q_OBJECT
private:
  ScriptRunner* scriptRunner = Q_NULLPTR;
  TurnTableCodec* turnTableCodec = Q_NULLPTR;
  TurnTableRunningStateManager* turnTableRunningStateManager = Q_NULLPTR;
public:
  InstructionTurnTableOpenCircuit()
  {
    scriptRunner = ScriptInstruction::getScriptRunner();
    turnTableCodec = ScriptInstruction::getTurnTableCodec();
    turnTableRunningStateManager = ScriptInstruction::getTurnTableRunningStateManager();
    instructionFlag = Instruction_TurnTable_OpenCircuit;
  }
  ~InstructionTurnTableOpenCircuit()
  {}
public:
  void run()override
  {
    turnTableCodec->sendInstruction(TurnTableCodec::TurnTable_OpenCircuit , 0, 0, 0);
    StateChecker<TurnTableCodec::TurnTableCircuitState, TurnTableRunningStateManager>::next_ifConditionReached(&TurnTableRunningStateManager::getState_turnTable_circuit, turnTableRunningStateManager, TurnTableCodec::State_CircuitOpened, scriptRunner->getInterval_turnTableOperationTimeOut(),scriptRunner);
  }
  QVector<float> getDataForSaving()override
  {
    QVector<float> savingData;
    savingData.append(instructionFlag);
    return savingData;
  }
};
#endif
